package com.coolingme.general;

/**
 * 享元模式测试
 *
 * @author wangyue
 * @date 2020-09-16 22:51
 */
public class Test {

    public static void main(String[] args) {
        // flyweight2和flyweight3 的内部状态相同，所以对象就是同一个
        IFlyweight flyweight1 = FlyweightFactory.getFlyweight("内部状态1");
        IFlyweight flyweight2 = FlyweightFactory.getFlyweight("内部状态2");
        IFlyweight flyweight3 = FlyweightFactory.getFlyweight("内部状态2");

        System.out.println(flyweight1);
        System.out.println(flyweight2);
        System.out.println(flyweight3);

        flyweight1.operation("a");
        flyweight2.operation("b");
        flyweight3.operation("c");
    }

}
